//
//  HealthSecondViewController.m
//  FoodList
//
//  Created by 王金晶 on 16/4/12.
//  Copyright © 2016年 王金晶. All rights reserved.
//

#import "HealthSecondViewController.h"
#import "RequestManger.h"
@interface HealthSecondViewController ()<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UILabel *title1;

@property (weak, nonatomic) IBOutlet UILabel *date;
@property (weak, nonatomic) IBOutlet UILabel *from;
@property(nonatomic,strong)NSMutableString *htmlStr;
@end

@implementation HealthSecondViewController
- (void)getData:(NSNumber *)number
{
    [RequestManger requestWithURL:[NSString stringWithFormat:@"http://lohas.mamashai.com/api/articles/show/%@",number] requestType:@"RequestGet"parDic:nil finish:^(NSData *data) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"%@",dic);
        _htmlStr = [NSMutableString string];
        _htmlStr = dic[@"article_content"][@"content"];
        NSLog(@"%@",_htmlStr);
        dispatch_async(dispatch_get_main_queue(), ^{
            [_webView loadHTMLString:_htmlStr baseURL:nil];
        });
    } error:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.title = @"养生";
    
    self.title1.text = _model.title;
    NSString *string = _model.updated_at;
    string = [string substringToIndex:10];
    self.date.text = string;
    self.from.text = _model.origin_url;
    
    [self getData:_model.myID];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
